//
//  SeeAskViewController.m
//  PropertyManager
//
//  Created by TNG on 2018/7/30.
//  Copyright © 2018年 Tng. All rights reserved.
//

#import "SeeAskViewController.h"
#import "SeeManagerAskTableViewCell.h"

@interface SeeAskViewController () <UITableViewDelegate,UITableViewDataSource>

@property (strong, nonatomic) UITableView * tableview;

@end

@implementation SeeAskViewController

static NSString * cellID = @"cell";
static NSString * SeeManagerAskTableViewCellID = @"SeeManagerAskTableViewCell";
static NSString * SeeManagerAskContentTableViewCellID = @"SeeManagerAskContentTableViewCell";
static NSString * SeeComplianContentTableViewCellID = @"SeeComplianContentTableViewCell";
static NSString * SeeUserComplainContentContentTableViewCellID = @"SeeUserComplainContentContentTableViewCell";
static NSString * SeeAskUserImgTableViewCellID = @"SeeAskUserImgTableViewCell";

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"查看回复";
    [self creatTableview];
    [self registCell];
}

-(void)registCell
{
    [self.tableview registerClass:[UITableViewCell class] forCellReuseIdentifier:cellID];
    [self.tableview registerClass:[SeeManagerAskTableViewCell class] forCellReuseIdentifier:SeeManagerAskTableViewCellID];
    [self.tableview registerClass:[SeeManagerAskContentTableViewCell class] forCellReuseIdentifier:SeeManagerAskContentTableViewCellID];
    [self.tableview registerClass:[SeeComplianContentTableViewCell class] forCellReuseIdentifier:SeeComplianContentTableViewCellID];
    [self.tableview registerClass:[SeeUserComplainContentContentTableViewCell class] forCellReuseIdentifier:SeeUserComplainContentContentTableViewCellID];
    [self.tableview registerClass:[SeeAskUserImgTableViewCell class] forCellReuseIdentifier:SeeAskUserImgTableViewCellID];
}

-(void)creatTableview{
    if (self.tableview == nil) {
        UITableView * tableview = [[UITableView alloc] initWithFrame:CGRectMake(0, kStatusAndNavBarH, WIDTH, HEIGHT - kStatusAndNavBarH - kHomeLineH) style:UITableViewStyleGrouped];
        tableview.delegate = self;
        tableview.dataSource = self;
        tableview.backgroundColor = SFMWhiteColor;
        tableview.separatorStyle = UITableViewCellSeparatorStyleNone;
        if (@available(iOS 11.0, *)) {
            tableview.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAutomatic;
        }
        self.tableview = tableview;
        [self.view addSubview:self.tableview];
    }
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        return 64;
    }else if (indexPath.row == 1)
    {
        NSString * str = @"如果你无法简洁的表达你的想法，那只说明你还不够了解它。如果你无法简洁的表达你的想法，那只说明你还不够了解它。如果你无法简洁的表达你的想法，那只说明你不够了解他";
        CGFloat height = [str boundingRectWithSize:CGSizeMake(WIDTH - 40, MAXFLOAT) withTextFont:font(14)].height;
        return height + 20;
    }else if(indexPath.row == 2)
    {
        return 55;
    }else if(indexPath.row == 3)
    {
        NSString * str = @"如果你无法简洁的表达你的想法，那只说明你还不够了解它。如果你无法简洁的表达你的想法，那只说明你还不够了解它。如果你无法简洁的表达你的想法，那只说明你不够了解他";
        CGFloat height = [str boundingRectWithSize:CGSizeMake(WIDTH - 40, MAXFLOAT) withTextFont:font(14)].height;
        return height + 20;
    }else
    {
        return (WIDTH - 94)/4 * 2 + 10 * 1 + 50;
    }
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    return [UIView new];
}

-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    return [UIView new];
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0.01;
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.01;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 5;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        SeeManagerAskTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:SeeManagerAskTableViewCellID];
        [cell send];
        return cell;
    }else if (indexPath.row == 1)
    {
        SeeManagerAskContentTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:SeeManagerAskContentTableViewCellID];
        [cell send];
        return cell;
    }else if (indexPath.row == 2)
    {
        SeeComplianContentTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:SeeComplianContentTableViewCellID];
        [cell send];
        return cell;
    }else if (indexPath.row == 3)
    {
        SeeUserComplainContentContentTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:SeeUserComplainContentContentTableViewCellID];
        [cell send];
        return cell;
    }else
    {
        SeeAskUserImgTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:SeeAskUserImgTableViewCellID];
        [cell send];
        return cell;
    }
    
//    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellID];
//    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
